class code1 {
    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
        //链表实现两数相加
        ListNode ret = new ListNode(0);//虚拟结点
        ListNode cur1 = l1,cur2 = l2;
        ListNode cur = ret;
        int t = 0;//记录进位
        while(cur1!=null || cur2!=null|| t==1) {
            //计算t
            if(cur1!=null) {
                t += cur1.val;
                cur1 = cur1.next;
            }
            if(cur2!=null) {
                t += cur2.val;
                cur2 = cur2.next;
            }
            cur.next = new ListNode(t%10);
            cur = cur.next;
            t /= 10;
        }
        return ret.next;
    }
}